package com.easy.order.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.common.bean.OrderItems;
import com.easy.common.service.IOrdersService;
import com.easy.common.service.IOrdersService;
import com.easy.common.util.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("orderitems")
public class OrderItemsController {
    @Autowired
    IOrdersService ordersService;
    @PostMapping("/")
    public ResultData insert(@RequestBody OrderItems orderitems){
        OrderItems result=ordersService.insertItem(orderitems);
        return ResultData.success(result);
    }
    @PutMapping("/")
    public ResultData update(@RequestBody OrderItems orderitems){
        return ResultData.success(ordersService.updateItem(orderitems));
    }
    @DeleteMapping("/{id}")
    public ResultData delete(@PathVariable Integer id){
        int result=ordersService.deleteItem(id);
        if(result>=1){
            return ResultData.success();
        }else{
            return ResultData.fail();
        }
    }
}
